package example.demo;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import java.util.Set;
import java.util.concurrent.Exchanger;
import java.util.concurrent.locks.LockSupport;

@Slf4j
@SpringBootApplication
public class SpringBootApp {
    public static Exchanger<Set<String>> urls = new Exchanger<>();

    public static void main(String[] args) {
        new Thread(() -> {
            try {
                Set<String> exchange = urls.exchange(null);
                exchange.stream().map(url -> "收集到的---url==>" + url).forEach(System.out::println);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }, "collect-thread").start();
        SpringApplication.run(SpringBootApp.class);
    }
}
